<!--
 * @Description: 
 * @Version: 
 * @Author: 学渣小明
 * @Date: 2022-05-03 11:19:47
 * @LastEditors: 学渣小明
 * @LastEditTime: 2022-05-03 12:12:46
-->
<div id="large">
    <div class="hot-search" id="fragment-recommend-bid" data-num="10" data-keyword="电梯">
        <div class="title">
            <h2 class="title_h2">
              <i class="title-line"></i>
              <a href="javascript:">大标推荐</a>
            </h2>
            <ul class="tab-list">
                <li class="active">日</li>
                <li>周</li>
            </ul>
        </div>
        <ul class="hot-search-list">
    
        </ul>
    </div>
</div>

<script>
    function getQueryBidTitle(type) {
        var now = new Date(
            $.ajax({
                url: '',
                async: false,
                method: 'get',
                dataType: '',
                context: document.body,
            }).getResponseHeader("Date")
        );

        var sevenAgo = new Date(now.getTime()-7*24*60*60*1000);
        var data = {
            pageNum: 0,
            pageSize: $('#fragment-recommend-bid').data('num'),
            queryText: $('#fragment-recommend-bid').data('keyword')
        };
        if(type==2){
            data = {
                pageNum: 0,
                pageSize: $('#fragment-recommend-bid').data('num'),
                queryText: "电梯",
                startTime:sevenAgo.getFullYear()+'-'+(sevenAgo.getMonth()+1)+'-'+sevenAgo.getDate()+' 00:00:00',
                endTime:now.getFullYear()+'-'+(now.getMonth()+1)+'-'+now.getDate()+' 23:59:59'
            }
        }
        $.ajax({
            url:ports.queryBidTitle,
            data:data,
            success:function (res) {
                console.log('查询大标推荐列表',res);
                if(res.status == 200){
                    var html = '';
                    $.each(res.data.content,function (i,item) {
                        html += '<li>\n' +
                            '<h3><a href='+ 'https://yzb.caigou2003.com/index.html#/bid/detail?id='+item.id +' target="_blank"><icon class="'+ 'icon-rank '+ (i<3?'hexagon':'') +' rank-' + (i+1) +'">'+ (i+1) +'</icon>\n' +
                            '    <span>'+ item.title +'</span>\n' +
                            '</a></h3></li>'
                    });
                    $('#fragment-recommend-bid .hot-search-list').html(html);
                }

            }
        })
    }
    getQueryBidTitle(1);
    var $aTabLi = $('.hot-search ul.tab-list>li');
    $aTabLi.click(function () {
        $(this).addClass('active').siblings().removeClass('active');

        console.log($(this).index())
        if($(this).index()==0){
            getQueryBidTitle(1)
        }else{
            getQueryBidTitle(2)
        }
    });
</script>